package com.ruoyi.web.controller.cashier;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.SyEmployeeServiceReservation;
import com.ruoyi.system.domain.SySelfBookingRefundOrder;
import com.ruoyi.system.dto.SyEmployeeServiceReservationDTO;
import com.ruoyi.system.service.SyEmployeeServiceReservationService;
import com.ruoyi.system.util.BaseResponse;
import com.ruoyi.system.util.StoreIdUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/service/reservation")
@Api(tags = "员工服务预订管理")
public class SyEmployeeServiceReservationController extends BaseController {

    @Autowired
    private SyEmployeeServiceReservationService reservationService;

    @Autowired
    private StoreIdUtils storeIdUtils;

    @GetMapping("/{id}")
    @ApiOperation("根据ID查询预订信息")
    public AjaxResult getById(@PathVariable Long id) {
        return AjaxResult.success(reservationService.getById(id));
    }

    @PostMapping("/list")
    @ApiOperation("分页查询所有预订记录")
    public BaseResponse<IPage<SyEmployeeServiceReservation>> list(@RequestBody SyEmployeeServiceReservationDTO reservationDTO) {
        IPage<SyEmployeeServiceReservation> all = reservationService.getAll(reservationDTO);
        return BaseResponse.success(all);
    }

    @PostMapping
    @ApiOperation("新增预订记录")
    public AjaxResult add(@RequestBody SyEmployeeServiceReservation reservation) {
        reservation.setStoreId(storeIdUtils.getStoreId());
        reservationService.save(reservation);
        return AjaxResult.success();
    }

    @PutMapping
    @ApiOperation("更新预订记录")
    public AjaxResult update(@RequestBody SyEmployeeServiceReservation reservation) {
        reservationService.updateById(reservation);
        return AjaxResult.success();
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除预订记录")
    public AjaxResult delete(@PathVariable Long id) {
        reservationService.removeById(id);
        return AjaxResult.success();
    }
}
